using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;

namespace Adex
{
	/// <summary>
	/// Strongly-typed collection for the TblSearchAll class.
	/// </summary>
	[Serializable]
	public partial class TblSearchAllCollection : ActiveList<TblSearchAll, TblSearchAllCollection> 
	{	   
		public TblSearchAllCollection() {}

	}

	/// <summary>
	/// This is an ActiveRecord class which wraps the tblSearchAll table.
	/// </summary>
	[Serializable]
	public partial class TblSearchAll : ActiveRecord<TblSearchAll>
	{
		#region .ctors and Default Settings
		
		public TblSearchAll()
		{
		  SetSQLProps();
		  InitSetDefaults();
		  MarkNew();
		}

		
		private void InitSetDefaults() { SetDefaults(); }

		
		public TblSearchAll(bool useDatabaseDefaults)
		{
			SetSQLProps();
			if(useDatabaseDefaults)
				ForceDefaults();
			MarkNew();
		}

		public TblSearchAll(object keyID)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByKey(keyID);
		}

		 
		public TblSearchAll(string columnName, object columnValue)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByParam(columnName,columnValue);
		}

		
		protected static void SetSQLProps() { GetTableSchema(); }

		
		#endregion
		
		#region Schema and Query Accessor
		public static Query CreateQuery() { return new Query(Schema); }

		
		public static TableSchema.Table Schema
		{
			get
			{
				if (BaseSchema == null)
					SetSQLProps();
				return BaseSchema;
			}

		}

		
		private static void GetTableSchema() 
		{
			if(!IsSchemaInitialized)
			{
				//Schema declaration
				TableSchema.Table schema = new TableSchema.Table("tblSearchAll", TableType.Table, DataService.GetInstance("Adex"));
				schema.Columns = new TableSchema.TableColumnCollection();
				schema.SchemaName = @"dbo";
				//columns
				
				TableSchema.TableColumn colvarId = new TableSchema.TableColumn(schema);
				colvarId.ColumnName = "ID";
				colvarId.DataType = DbType.Int32;
				colvarId.MaxLength = 0;
				colvarId.AutoIncrement = true;
				colvarId.IsNullable = false;
				colvarId.IsPrimaryKey = true;
				colvarId.IsForeignKey = false;
				colvarId.IsReadOnly = false;
				colvarId.DefaultSetting = @"";
				colvarId.ForeignKeyTableName = "";
				schema.Columns.Add(colvarId);
				
				TableSchema.TableColumn colvarSiteUserID = new TableSchema.TableColumn(schema);
				colvarSiteUserID.ColumnName = "SiteUserID";
				colvarSiteUserID.DataType = DbType.Int32;
				colvarSiteUserID.MaxLength = 0;
				colvarSiteUserID.AutoIncrement = false;
				colvarSiteUserID.IsNullable = false;
				colvarSiteUserID.IsPrimaryKey = false;
				colvarSiteUserID.IsForeignKey = false;
				colvarSiteUserID.IsReadOnly = false;
				colvarSiteUserID.DefaultSetting = @"";
				colvarSiteUserID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarSiteUserID);
				
				TableSchema.TableColumn colvarMediaType = new TableSchema.TableColumn(schema);
				colvarMediaType.ColumnName = "MediaType";
				colvarMediaType.DataType = DbType.String;
				colvarMediaType.MaxLength = 50;
				colvarMediaType.AutoIncrement = false;
				colvarMediaType.IsNullable = false;
				colvarMediaType.IsPrimaryKey = false;
				colvarMediaType.IsForeignKey = false;
				colvarMediaType.IsReadOnly = false;
				colvarMediaType.DefaultSetting = @"";
				colvarMediaType.ForeignKeyTableName = "";
				schema.Columns.Add(colvarMediaType);
				
				TableSchema.TableColumn colvarTVChannels = new TableSchema.TableColumn(schema);
				colvarTVChannels.ColumnName = "TVChannels";
				colvarTVChannels.DataType = DbType.String;
				colvarTVChannels.MaxLength = -1;
				colvarTVChannels.AutoIncrement = false;
				colvarTVChannels.IsNullable = true;
				colvarTVChannels.IsPrimaryKey = false;
				colvarTVChannels.IsForeignKey = false;
				colvarTVChannels.IsReadOnly = false;
				colvarTVChannels.DefaultSetting = @"";
				colvarTVChannels.ForeignKeyTableName = "";
				schema.Columns.Add(colvarTVChannels);
				
				TableSchema.TableColumn colvarRadioChannels = new TableSchema.TableColumn(schema);
				colvarRadioChannels.ColumnName = "RadioChannels";
				colvarRadioChannels.DataType = DbType.String;
				colvarRadioChannels.MaxLength = -1;
				colvarRadioChannels.AutoIncrement = false;
				colvarRadioChannels.IsNullable = true;
				colvarRadioChannels.IsPrimaryKey = false;
				colvarRadioChannels.IsForeignKey = false;
				colvarRadioChannels.IsReadOnly = false;
				colvarRadioChannels.DefaultSetting = @"";
				colvarRadioChannels.ForeignKeyTableName = "";
				schema.Columns.Add(colvarRadioChannels);
				
				TableSchema.TableColumn colvarCableChannels = new TableSchema.TableColumn(schema);
				colvarCableChannels.ColumnName = "CableChannels";
				colvarCableChannels.DataType = DbType.String;
				colvarCableChannels.MaxLength = -1;
				colvarCableChannels.AutoIncrement = false;
				colvarCableChannels.IsNullable = true;
				colvarCableChannels.IsPrimaryKey = false;
				colvarCableChannels.IsForeignKey = false;
				colvarCableChannels.IsReadOnly = false;
				colvarCableChannels.DefaultSetting = @"";
				colvarCableChannels.ForeignKeyTableName = "";
				schema.Columns.Add(colvarCableChannels);
				
				TableSchema.TableColumn colvarPressMedia = new TableSchema.TableColumn(schema);
				colvarPressMedia.ColumnName = "PressMedia";
				colvarPressMedia.DataType = DbType.String;
				colvarPressMedia.MaxLength = -1;
				colvarPressMedia.AutoIncrement = false;
				colvarPressMedia.IsNullable = true;
				colvarPressMedia.IsPrimaryKey = false;
				colvarPressMedia.IsForeignKey = false;
				colvarPressMedia.IsReadOnly = false;
				colvarPressMedia.DefaultSetting = @"";
				colvarPressMedia.ForeignKeyTableName = "";
				schema.Columns.Add(colvarPressMedia);
				
				TableSchema.TableColumn colvarInternetMedia = new TableSchema.TableColumn(schema);
				colvarInternetMedia.ColumnName = "InternetMedia";
				colvarInternetMedia.DataType = DbType.String;
				colvarInternetMedia.MaxLength = -1;
				colvarInternetMedia.AutoIncrement = false;
				colvarInternetMedia.IsNullable = true;
				colvarInternetMedia.IsPrimaryKey = false;
				colvarInternetMedia.IsForeignKey = false;
				colvarInternetMedia.IsReadOnly = false;
				colvarInternetMedia.DefaultSetting = @"";
				colvarInternetMedia.ForeignKeyTableName = "";
				schema.Columns.Add(colvarInternetMedia);
				
				TableSchema.TableColumn colvarSector = new TableSchema.TableColumn(schema);
				colvarSector.ColumnName = "Sector";
				colvarSector.DataType = DbType.String;
				colvarSector.MaxLength = 50;
				colvarSector.AutoIncrement = false;
				colvarSector.IsNullable = true;
				colvarSector.IsPrimaryKey = false;
				colvarSector.IsForeignKey = false;
				colvarSector.IsReadOnly = false;
				colvarSector.DefaultSetting = @"";
				colvarSector.ForeignKeyTableName = "";
				schema.Columns.Add(colvarSector);
				
				TableSchema.TableColumn colvarSubSector = new TableSchema.TableColumn(schema);
				colvarSubSector.ColumnName = "SubSector";
				colvarSubSector.DataType = DbType.String;
				colvarSubSector.MaxLength = 50;
				colvarSubSector.AutoIncrement = false;
				colvarSubSector.IsNullable = true;
				colvarSubSector.IsPrimaryKey = false;
				colvarSubSector.IsForeignKey = false;
				colvarSubSector.IsReadOnly = false;
				colvarSubSector.DefaultSetting = @"";
				colvarSubSector.ForeignKeyTableName = "";
				schema.Columns.Add(colvarSubSector);
				
				TableSchema.TableColumn colvarCategory = new TableSchema.TableColumn(schema);
				colvarCategory.ColumnName = "Category";
				colvarCategory.DataType = DbType.String;
				colvarCategory.MaxLength = 50;
				colvarCategory.AutoIncrement = false;
				colvarCategory.IsNullable = true;
				colvarCategory.IsPrimaryKey = false;
				colvarCategory.IsForeignKey = false;
				colvarCategory.IsReadOnly = false;
				colvarCategory.DefaultSetting = @"";
				colvarCategory.ForeignKeyTableName = "";
				schema.Columns.Add(colvarCategory);
				
				TableSchema.TableColumn colvarAdvertiser = new TableSchema.TableColumn(schema);
				colvarAdvertiser.ColumnName = "Advertiser";
				colvarAdvertiser.DataType = DbType.String;
				colvarAdvertiser.MaxLength = 50;
				colvarAdvertiser.AutoIncrement = false;
				colvarAdvertiser.IsNullable = true;
				colvarAdvertiser.IsPrimaryKey = false;
				colvarAdvertiser.IsForeignKey = false;
				colvarAdvertiser.IsReadOnly = false;
				colvarAdvertiser.DefaultSetting = @"";
				colvarAdvertiser.ForeignKeyTableName = "";
				schema.Columns.Add(colvarAdvertiser);
				
				TableSchema.TableColumn colvarAgency = new TableSchema.TableColumn(schema);
				colvarAgency.ColumnName = "Agency";
				colvarAgency.DataType = DbType.String;
				colvarAgency.MaxLength = 50;
				colvarAgency.AutoIncrement = false;
				colvarAgency.IsNullable = true;
				colvarAgency.IsPrimaryKey = false;
				colvarAgency.IsForeignKey = false;
				colvarAgency.IsReadOnly = false;
				colvarAgency.DefaultSetting = @"";
				colvarAgency.ForeignKeyTableName = "";
				schema.Columns.Add(colvarAgency);
				
				TableSchema.TableColumn colvarProduct = new TableSchema.TableColumn(schema);
				colvarProduct.ColumnName = "Product";
				colvarProduct.DataType = DbType.String;
				colvarProduct.MaxLength = 350;
				colvarProduct.AutoIncrement = false;
				colvarProduct.IsNullable = true;
				colvarProduct.IsPrimaryKey = false;
				colvarProduct.IsForeignKey = false;
				colvarProduct.IsReadOnly = false;
				colvarProduct.DefaultSetting = @"";
				colvarProduct.ForeignKeyTableName = "";
				schema.Columns.Add(colvarProduct);
				
				TableSchema.TableColumn colvarIscategory = new TableSchema.TableColumn(schema);
				colvarIscategory.ColumnName = "Iscategory";
				colvarIscategory.DataType = DbType.Boolean;
				colvarIscategory.MaxLength = 0;
				colvarIscategory.AutoIncrement = false;
				colvarIscategory.IsNullable = true;
				colvarIscategory.IsPrimaryKey = false;
				colvarIscategory.IsForeignKey = false;
				colvarIscategory.IsReadOnly = false;
				colvarIscategory.DefaultSetting = @"";
				colvarIscategory.ForeignKeyTableName = "";
				schema.Columns.Add(colvarIscategory);
				
				TableSchema.TableColumn colvarIsProduct = new TableSchema.TableColumn(schema);
				colvarIsProduct.ColumnName = "IsProduct";
				colvarIsProduct.DataType = DbType.Boolean;
				colvarIsProduct.MaxLength = 0;
				colvarIsProduct.AutoIncrement = false;
				colvarIsProduct.IsNullable = true;
				colvarIsProduct.IsPrimaryKey = false;
				colvarIsProduct.IsForeignKey = false;
				colvarIsProduct.IsReadOnly = false;
				colvarIsProduct.DefaultSetting = @"";
				colvarIsProduct.ForeignKeyTableName = "";
				schema.Columns.Add(colvarIsProduct);
				
				TableSchema.TableColumn colvarIsAdvertiser = new TableSchema.TableColumn(schema);
				colvarIsAdvertiser.ColumnName = "IsAdvertiser";
				colvarIsAdvertiser.DataType = DbType.Boolean;
				colvarIsAdvertiser.MaxLength = 0;
				colvarIsAdvertiser.AutoIncrement = false;
				colvarIsAdvertiser.IsNullable = true;
				colvarIsAdvertiser.IsPrimaryKey = false;
				colvarIsAdvertiser.IsForeignKey = false;
				colvarIsAdvertiser.IsReadOnly = false;
				colvarIsAdvertiser.DefaultSetting = @"";
				colvarIsAdvertiser.ForeignKeyTableName = "";
				schema.Columns.Add(colvarIsAdvertiser);
				
				TableSchema.TableColumn colvarLayout = new TableSchema.TableColumn(schema);
				colvarLayout.ColumnName = "Layout";
				colvarLayout.DataType = DbType.String;
				colvarLayout.MaxLength = 350;
				colvarLayout.AutoIncrement = false;
				colvarLayout.IsNullable = false;
				colvarLayout.IsPrimaryKey = false;
				colvarLayout.IsForeignKey = false;
				colvarLayout.IsReadOnly = false;
				colvarLayout.DefaultSetting = @"";
				colvarLayout.ForeignKeyTableName = "";
				schema.Columns.Add(colvarLayout);
				
				BaseSchema = schema;
				//add this schema to the provider
				//so we can query it later
				DataService.Providers["Adex"].AddSchema("tblSearchAll",schema);
			}

		}

		#endregion
		
		#region Props
		
		  
		[XmlAttribute("Id")]
		public int Id 
		{
			get { return GetColumnValue<int>("ID"); }

			set { SetColumnValue("ID", value); }

		}

		  
		[XmlAttribute("SiteUserID")]
		public int SiteUserID 
		{
			get { return GetColumnValue<int>("SiteUserID"); }

			set { SetColumnValue("SiteUserID", value); }

		}

		  
		[XmlAttribute("MediaType")]
		public string MediaType 
		{
			get { return GetColumnValue<string>("MediaType"); }

			set { SetColumnValue("MediaType", value); }

		}

		  
		[XmlAttribute("TVChannels")]
		public string TVChannels 
		{
			get { return GetColumnValue<string>("TVChannels"); }

			set { SetColumnValue("TVChannels", value); }

		}

		  
		[XmlAttribute("RadioChannels")]
		public string RadioChannels 
		{
			get { return GetColumnValue<string>("RadioChannels"); }

			set { SetColumnValue("RadioChannels", value); }

		}

		  
		[XmlAttribute("CableChannels")]
		public string CableChannels 
		{
			get { return GetColumnValue<string>("CableChannels"); }

			set { SetColumnValue("CableChannels", value); }

		}

		  
		[XmlAttribute("PressMedia")]
		public string PressMedia 
		{
			get { return GetColumnValue<string>("PressMedia"); }

			set { SetColumnValue("PressMedia", value); }

		}

		  
		[XmlAttribute("InternetMedia")]
		public string InternetMedia 
		{
			get { return GetColumnValue<string>("InternetMedia"); }

			set { SetColumnValue("InternetMedia", value); }

		}

		  
		[XmlAttribute("Sector")]
		public string Sector 
		{
			get { return GetColumnValue<string>("Sector"); }

			set { SetColumnValue("Sector", value); }

		}

		  
		[XmlAttribute("SubSector")]
		public string SubSector 
		{
			get { return GetColumnValue<string>("SubSector"); }

			set { SetColumnValue("SubSector", value); }

		}

		  
		[XmlAttribute("Category")]
		public string Category 
		{
			get { return GetColumnValue<string>("Category"); }

			set { SetColumnValue("Category", value); }

		}

		  
		[XmlAttribute("Advertiser")]
		public string Advertiser 
		{
			get { return GetColumnValue<string>("Advertiser"); }

			set { SetColumnValue("Advertiser", value); }

		}

		  
		[XmlAttribute("Agency")]
		public string Agency 
		{
			get { return GetColumnValue<string>("Agency"); }

			set { SetColumnValue("Agency", value); }

		}

		  
		[XmlAttribute("Product")]
		public string Product 
		{
			get { return GetColumnValue<string>("Product"); }

			set { SetColumnValue("Product", value); }

		}

		  
		[XmlAttribute("Iscategory")]
		public bool? Iscategory 
		{
			get { return GetColumnValue<bool?>("Iscategory"); }

			set { SetColumnValue("Iscategory", value); }

		}

		  
		[XmlAttribute("IsProduct")]
		public bool? IsProduct 
		{
			get { return GetColumnValue<bool?>("IsProduct"); }

			set { SetColumnValue("IsProduct", value); }

		}

		  
		[XmlAttribute("IsAdvertiser")]
		public bool? IsAdvertiser 
		{
			get { return GetColumnValue<bool?>("IsAdvertiser"); }

			set { SetColumnValue("IsAdvertiser", value); }

		}

		  
		[XmlAttribute("Layout")]
		public string Layout 
		{
			get { return GetColumnValue<string>("Layout"); }

			set { SetColumnValue("Layout", value); }

		}

		
		#endregion
		
		
			
		
		//no foreign key tables defined (0)
		
		
		
		//no ManyToMany tables defined (0)
		
		#region ObjectDataSource support
		
		
		/// <summary>
		/// Inserts a record, can be used with the Object Data Source
		/// </summary>
		public static void Insert(int varSiteUserID,string varMediaType,string varTVChannels,string varRadioChannels,string varCableChannels,string varPressMedia,string varInternetMedia,string varSector,string varSubSector,string varCategory,string varAdvertiser,string varAgency,string varProduct,bool? varIscategory,bool? varIsProduct,bool? varIsAdvertiser,string varLayout)
		{
			TblSearchAll item = new TblSearchAll();
			
			item.SiteUserID = varSiteUserID;
			
			item.MediaType = varMediaType;
			
			item.TVChannels = varTVChannels;
			
			item.RadioChannels = varRadioChannels;
			
			item.CableChannels = varCableChannels;
			
			item.PressMedia = varPressMedia;
			
			item.InternetMedia = varInternetMedia;
			
			item.Sector = varSector;
			
			item.SubSector = varSubSector;
			
			item.Category = varCategory;
			
			item.Advertiser = varAdvertiser;
			
			item.Agency = varAgency;
			
			item.Product = varProduct;
			
			item.Iscategory = varIscategory;
			
			item.IsProduct = varIsProduct;
			
			item.IsAdvertiser = varIsAdvertiser;
			
			item.Layout = varLayout;
			
		
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}

		
		/// <summary>
		/// Updates a record, can be used with the Object Data Source
		/// </summary>
		public static void Update(int varId,int varSiteUserID,string varMediaType,string varTVChannels,string varRadioChannels,string varCableChannels,string varPressMedia,string varInternetMedia,string varSector,string varSubSector,string varCategory,string varAdvertiser,string varAgency,string varProduct,bool? varIscategory,bool? varIsProduct,bool? varIsAdvertiser,string varLayout)
		{
			TblSearchAll item = new TblSearchAll();
			
				item.Id = varId;
				
				item.SiteUserID = varSiteUserID;
				
				item.MediaType = varMediaType;
				
				item.TVChannels = varTVChannels;
				
				item.RadioChannels = varRadioChannels;
				
				item.CableChannels = varCableChannels;
				
				item.PressMedia = varPressMedia;
				
				item.InternetMedia = varInternetMedia;
				
				item.Sector = varSector;
				
				item.SubSector = varSubSector;
				
				item.Category = varCategory;
				
				item.Advertiser = varAdvertiser;
				
				item.Agency = varAgency;
				
				item.Product = varProduct;
				
				item.Iscategory = varIscategory;
				
				item.IsProduct = varIsProduct;
				
				item.IsAdvertiser = varIsAdvertiser;
				
				item.Layout = varLayout;
				
			item.IsNew = false;
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}

		#endregion
		#region Columns Struct
		public struct Columns
		{
			 public static string Id = @"ID";
			 public static string SiteUserID = @"SiteUserID";
			 public static string MediaType = @"MediaType";
			 public static string TVChannels = @"TVChannels";
			 public static string RadioChannels = @"RadioChannels";
			 public static string CableChannels = @"CableChannels";
			 public static string PressMedia = @"PressMedia";
			 public static string InternetMedia = @"InternetMedia";
			 public static string Sector = @"Sector";
			 public static string SubSector = @"SubSector";
			 public static string Category = @"Category";
			 public static string Advertiser = @"Advertiser";
			 public static string Agency = @"Agency";
			 public static string Product = @"Product";
			 public static string Iscategory = @"Iscategory";
			 public static string IsProduct = @"IsProduct";
			 public static string IsAdvertiser = @"IsAdvertiser";
			 public static string Layout = @"Layout";
						
		}

		#endregion
	}

}

